{extend name="admin@index_layout"/}
{block name="main"}
<div class="layui-card">
    <div class="layui-card-header">短消息管理</div>
    <div class="layui-card-body">
        <div class="layui-form">
            <table class="layui-hide" id="currentTable" lay-filter="currentTable"></table>
        </div>
    </div>
</div>
<script type="text/html" id="barTool">
    <a href='{:url("delete")}?ids={{ d.id }}' class="layui-btn layui-btn-danger layui-btn-xs layui-tr-del">删除</a>
</script>
{/block}
{block name="script"}
<script>
layui.use('yznTable', function() {
    var table = layui.yznTable;

    var init = {
        table_elem: '#currentTable',
        delete_url: "{:url('del')}",
    };

    table.render({
        init: init,
        id: 'currentTable',
        elem: '#currentTable',
        toolbar: ['refresh', 'delete',
            [{
                    text: '发送短消息',
                    url: "{:url('send_one')}",
                    method: 'open',
                    auth: 'add',
                    class: 'layui-btn layui-btn-sm',
                    extend: 'data-full="false"',
                },
                {
                    html: '<a class="layui-btn layui-btn-sm layui-btn-danger" href="{:url("group")}">切换群发消息<span class="layui-badge-dot layui-bg-orange"></span></a>'
                }
            ],
        ],
        url: '{:url("index")}',
        cols: [
            [
                { type: 'checkbox', fixed: 'left' },
                { field: 'id', width: 70, title: 'ID' },
                { field: 'subject',align: "left", width: 200, title: '标题' },
                { field: 'content',align: "left", title: '内容' },
                { field: 'send_from', width: 120, title: '发件人' },
                { field: 'send_to', width: 120, title: '收件人' },
                { field: 'create_time', width: 200, align: "center", title: '发送时间' },
                { fixed: 'right', width: 80, title: '操作', toolbar: '#barTool' }
            ]
        ],
    });
});
</script>
{/block}